home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / star-1_0.tar / sparse.h < prev    next >
C/C++ Source or Header  |  1991-03-22  |  1KB  |  59 lines

  1. /*
  2.  * sparse.h - Sparse arrays header file
  3.  *
  4.  */
  5.  
  6.  
  7. /* Vanilla constants */
  8. #define SPR_NODD 8        /* Node depth, in levels */
  9. #define SPR_SHFC 4        /* 2 log of # of indexes per node */
  10.  
  11. /* Extract bit field */
  12. #define SPR_I2X(C,I,F) \
  13.   ( ((I) >> ((F) * (C)->spr_shfc)) & (C)->spr_mask )
  14.  
  15. /* Sparse array node */
  16. typedef struct _sparse_
  17.   {
  18.     short
  19.       spr_inuse;        /* # of links in use */
  20.  
  21.     struct _sparse_
  22.       *spr_link[ 1 ];        /* Links */
  23.   }
  24. SPR_NODE;
  25.  
  26.  
  27. /* Sparse array header */
  28. typedef struct
  29.  {
  30.    char *spr_id;        /* Identifier/reference */
  31.  
  32.    short
  33.      spr_nodd,            /* Node depth */
  34.      spr_mask,            /* (1 << (spr_shfc)) - 1 */
  35.      spr_shfc,            /* Shift count */
  36.      spr_inuse;            /* Nodes in use */
  37.  
  38.    SPR_NODE
  39.      *(*spr_create)(),        /* Node creation (malloc(3) compatible) */
  40.      *spr_top;            /* Top node */
  41.  
  42.    void
  43.      (*spr_destr)();        /* Node destruction (free(3) compatible) */
  44.  }
  45. SPR_ROOT;
  46.  
  47.  
  48. /* Functions */
  49. extern SPR_ROOT
  50.   *spr_open();            /* Create sparse array */
  51.  
  52. extern char
  53.   *spr_get();            /* Get value */
  54.  
  55. extern void
  56.   spr_close(),            /* Destroy sparse array */
  57.   spr_unbind(),            /* Unbind slot */
  58.   spr_bind();            /* Bind slot */
  59.